<template>
	<div>
		<el-card>
			<el-form :inline="true" :model="queryData" class="demo-form-inline">
				<el-form-item label="状态">
					<!-- <el-input v-model="queryData.query" placeholder="请输入昵称" /> -->
					<el-select
						v-model="queryData.query"
						style="width: 192px"
						placeholder="请选择状态"
					>
						<el-option label="全部" value="" />
						<el-option label="已回复" value="1" />
						<el-option label="未回复" value="0" />
					</el-select>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="onSubmit(1)">搜索</el-button>
				</el-form-item>
			</el-form>
			<el-table :data="pageData.list" border style="width: 100%">
				<el-table-column prop="feed_back" label="反馈内容" />
				<el-table-column prop="create_time" label="反馈时间" />
				<el-table-column label="是否已回复">
					<template #default="scpot">
						{{ scpot.row.dispose_state == '1' ? '是' : '否' }}
					</template>
				</el-table-column>
				<el-table-column prop="address" label="操作" width="120">
					<template #default="scpot">
						<el-button
							link
							type="primary"
							@click="router.push(`/users/feedbackdetails/${scpot.row.id}`)"
						>
							详情
						</el-button>
						<el-button
							link
							type="primary"
							v-if="scpot.row.dispose_state == '0'"
							@click="onNewmessage(scpot.row)"
						>
							回复
						</el-button>
					</template>
				</el-table-column>
			</el-table>
			<pagination
				:current="queryData.pageNum"
				:total="pageData.total"
				:pageSize="queryData.pageSize"
				@paginaClick="onSubmit"
			></pagination>
		</el-card>
	</div>
</template>
<script setup lang="ts">
import { reactive, ref } from 'vue';
import { getFeedbacklist } from '@/utils/api';
import { useRouter } from 'vue-router';
const router = useRouter();
const pageData: any = ref({});
const queryData = reactive({
	query: '',
	pageNum: 1,
	pageSize: 10,
});
const getPageData = () => {
	getFeedbacklist(queryData).then((res: any) => {
		pageData.value = res.data;
	});
};
getPageData();
const onSubmit = (val: number) => {
	queryData.pageNum = val;
	getPageData();
};
const onNewmessage = (row: any) => {
	router.push(`/message/newmessage?user_id=${row.user_id}&id=${row.id}`);
};
</script>
